import { stringify } from 'querystring';
import request from '@/utils/request';
import { DEFAULT_URL_STAFF } from '@/constants';

export async function getCurrentUser() {
    return request(`${DEFAULT_URL_STAFF}/getCurrentUser`);
}

export async function getCurrentUserUnit() {
    return request(`${DEFAULT_URL_STAFF}/getCurrentUserUnit`);
}

export async function getCurrentRoleMenuElement({ menuType }) {
    return request(`${DEFAULT_URL_STAFF}/getCurrentRoleMenuElement?menuType=${menuType}`);
}

export async function queryData(data) {
    debugger
    return request(`${DEFAULT_URL_STAFF}/queryObjForParams`, { method: 'POST', body: data });
}

export async function communicationQuery(data) {
    return request(`${DEFAULT_URL_STAFF}/communicationQuery`, { method: 'POST', body: data });
}

export async function saveData(option) {
    return request(`${DEFAULT_URL_STAFF}/saveObj`, option);
}

export async function updateData(option) {
    return request(`${DEFAULT_URL_STAFF}/modifyObj`, option);
}

export async function deleteData(option) {
    return request(`${DEFAULT_URL_STAFF}/forbidBatchObj`, option);
}

export async function downloadData(query, body) {
    return request(`${DEFAULT_URL_STAFF}/downloadData?${stringify(query)}`, { method: 'POST', body });
}

export async function uploadData(query, option) {
    return request(`${DEFAULT_URL_STAFF}/uploadBatchObj?${stringify(query)}`, option);
}

export async function updatePassword(query) {
    return request(`${DEFAULT_URL_STAFF}/updatePassword?${stringify(query)}`);
}

export async function getTelephone(query) {
    return request(`${DEFAULT_URL_STAFF}/queryPhoneNumber?${stringify(query)}`);
}